//
//  OTRExtraInsetLabel.m
//  TRoad2
//
//  Created by ZhangYanhua on 15/11/26.
//  Copyright © 2015年 Mach. All rights reserved.
//

#import "QWExtraInsetLabel.h"

@implementation QWExtraInsetLabel

- (void)setVerticalInset:(CGFloat)verticalInset
{
    NSAssert(verticalInset >= 0.0f, @"不能设置小于0的inset， 可能导致Label文字无法显示");
    
    _verticalInset = MAX(verticalInset, 0.0f);
    
    [self invalidateIntrinsicContentSize];
}

- (CGSize)intrinsicContentSize
{
    CGSize intrinsicSize = [super intrinsicContentSize];

    if (intrinsicSize.height != UIViewNoIntrinsicMetric) {
        intrinsicSize.height += 2 * _verticalInset;
    }
    
    return intrinsicSize;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
